package com.smkj.kaoqin.modules.admin.pojo.db;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 学生答案表
 * </p>
 *
 * @author 徐建彬
 * @since 2024-06-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("answer")
public class Answer implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 学生答案Id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 关联题目Id
     */
    private Long questionId;

    /**
     * 答案内容
     */
    private String content;
    /**
     * AI得分
     */
    private Double aiScore;
    /**
     * 得分分析
     */
    private String scoreAnaly;
    /**
     * 总分
     */
    private Double total;

    /**
     * 作答人Id—学生学号
     */
    private Long studentNum;

    /**
     * 答案状态：0保存、1提交
     */
    private Integer state;

    /**
     * 创建时间
     */
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    /**
     * 最后更新时间
     */
    @TableField(value = "update_time",fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;
    /**
     * 提交时间
     */
    private LocalDateTime submitTime;
    private Long serialNumber;


    // 复制非空属性的方法
    public void copyNonNullFieldsFrom(Answer source) {
        if (this.aiScore == null && source.getAiScore() != null) {
            this.aiScore = source.getAiScore();
        }
        if (this.total == null && source.getTotal() != null) {
            this.total = source.getTotal();
        }
        if ((this.scoreAnaly == null || this.scoreAnaly.equals("")) && source.getScoreAnaly() != null) {
            this.scoreAnaly = source.getScoreAnaly();
        }
    }

}
